<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
	$(function(){
		//페이지가 로딩할 때
		//r_type세션값이 null이 아니면 if문 안에 있는 로직을 수행한다.
		if(${sessionScope.recipe3==null}){
			$("#main_mainIngre_textarea").css("background-image","url(${initParam.root}/img/main/main-write3-ingrediant.gif)");
			$("#main_subIngre_textarea").css("background-image","url(${initParam.root}/img/main/main-write3-ingrediant.gif)");
		}else{
			//#r_mcnt select의 value를 그 값으로 고정시켜 띄워준다.
			$("#r_mcnt").val("${sessionScope.recipe3.r_mcnt}");
			$("#main_mainIngre_textarea").css("background-image","none");
			$("#main_subIngre_textarea").css("background-image","none");
		}
		// 글을 쓸 때에 배경글자를 없에준다.
		$("#main_mainIngre_textarea").focus(function(){
			$("#main_mainIngre_textarea").css("background-image","none");
		});
		$("#main_subIngre_textarea").focus(function(){
			$("#main_subIngre_textarea").css("background-image","none");
		});
		
		
		$("#main_arrow_next").click(function(){
			if($("#main_mainIngre_textarea").val()==""){
				alert("주재료를 입력하세요");
				return false;
			}
			if($("#main_subIngre_textarea").val()==""){
				alert("부재료를 입력하세요");
				return false;
			}
			$("#pForm_3").submit();
		});
		//2페이지로 가기 위해서 page 값을 2값을 줌
		$("#main_arrow_prev").click(function(){
			location.href="recipe.do?command=writePrev&page=2";
		});
		// 작성 취소 버튼
		$("#main_cancle").click(function(){
			if(confirm("작성을 취소하시겠습니까?")){
				location.href="recipe.do?command=write_cancle";
			}
		});
		
	});
</script>
<div id="write_container">
<!-- 공통부분 -->
<div id="main_page1"><img src="${initParam.root }/img/main/main-write-page3.gif"></div>
<div id="main_arrow_prev"><input type="image" src="${initParam.root }/img/main/main-write-prev.gif"></div>
<div id="main_arrow_next"><input type="image" src="${initParam.root }/img/main/main-write-next.gif"></div>
<div id="main_info_prev"><img src="${initParam.root }/img/main/main-write-prev-info.jpg"></div>
<div id="main_info_next"><img src="${initParam.root }/img/main/main-write-next-info.gif"></div>
<div id="main_cancle"><input type="image" src="${initParam.root }/img/main/main-write-cancle.gif"></div>
<!-- 여기부턴 이 페이지에서만 쓰임 -->
<div id="main_kind"><img src="${initParam.root }/img/main/main-write3-ready.gif"></div>
<div id="main_mctn"><img src="${initParam.root }/img/main/main-write3-mcnt.gif"></div>
<div id="main_mainIngre"><img src="${initParam.root }/img/main/main-write3-mainIngre.gif"></div>
<div id="main_subIngre"><img src="${initParam.root }/img/main/main-write3-subIngre.gif"></div>
	<div id="main_write_form">
	<!-- 데이터 전송용 폼 -->
 		<form id="pForm_3" action="recipe.do" method="post">
 		<input type="hidden" name="command" value="writeNext">
 		<!-- page 값은 Controller에서 현재 페이지를 구분하기 위해 사용 -->
 		<input type="hidden" name="page" value="4">
 		<c:choose>
		<c:when test="${sessionScope.recipe3==null }">
 		<div id="main_mctn_select">
 			<select name="r_mcnt">
				<option value="1">&nbsp;&nbsp;1&nbsp;&nbsp;</option>
				<option value="2">&nbsp;&nbsp;2&nbsp;&nbsp;</option>
				<option value="3">&nbsp;&nbsp;3&nbsp;&nbsp;</option>
				<option value="4">&nbsp;&nbsp;4&nbsp;&nbsp;</option>
			</select>인분
		</div>
 		<div id="main_mainIngre_text"><textarea id="main_mainIngre_textarea" cols="70" rows="7" name="r_main_ingre"></textarea></div>
 		<div id="main_subIngre_text"><textarea id="main_subIngre_textarea" cols="70" rows="7" name="r_sub_ingre"></textarea></div>
 		</c:when>
 		<c:otherwise>
 			<div id="main_mctn_select">
 			<select name="r_mcnt" id="r_mcnt">
				<option value="1">&nbsp;&nbsp;1&nbsp;&nbsp;</option>
				<option value="2">&nbsp;&nbsp;2&nbsp;&nbsp;</option>
				<option value="3">&nbsp;&nbsp;3&nbsp;&nbsp;</option>
				<option value="4">&nbsp;&nbsp;4&nbsp;&nbsp;</option>
			</select>인분
		</div>
 		<div id="main_mainIngre_text"><textarea id="main_mainIngre_textarea" cols="70" rows="7" name="r_main_ingre">${sessionScope.recipe3.r_main_ingre }</textarea></div>
 		<div id="main_subIngre_text"><textarea id="main_subIngre_textarea" cols="70" rows="7" name="r_sub_ingre">${sessionScope.recipe3.r_sub_ingre }</textarea></div>
 		</c:otherwise>
 		 </c:choose>
 		</form>
 	</div>
</div>